/*
 * TestFul - http://code.google.com/p/testful/
 * Copyright (C) 2012 Matteo Miraz
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package testful.evolutionary;

import java.util.List;

import jmetal.base.DecisionVariables;
import jmetal.base.Problem;
import jmetal.base.Solution;
import jmetal.base.Variable;
import testful.model.Operation;

/**
 * TODO describe me!
 * 
 * @author Administrator
 * @param <T>
 */
public class PSOSolution<T extends Variable> extends Solution<T> {

	/**
	 * TODO describe me!
	 */
	private static final long serialVersionUID = 1L;

	// individual best solution
	private List<T> iBest;

	private SwapOperation swapOp;

	public PSOSolution() {
		super();
		// TODO Auto-generated constructor stub
	}

	public PSOSolution(int numberOfObjectives) {
		super(numberOfObjectives);
		// TODO Auto-generated constructor stub
	}

	public PSOSolution(Problem<T> problem, DecisionVariables<T> variables) {
		super(problem, variables);
		List<Operation> opList = (List<Operation>) variables.variables_;
		Operation[] ops = new Operation[opList.size()];
		int i = 0;
		for(Operation o:opList){
			ops[i] = o;
			i++;
		}

		swapOp = new SwapOperation(((JMProblem) problem).getProblem(),ops);
		iBest = variables.variables_;
	}

	public PSOSolution(Problem<T> problem) {
		super(problem);

		List<Operation> opList = (List<Operation>) getDecisionVariables().variables_;
		Operation[] ops = new Operation[opList.size()];
		int i = 0;
		for(Operation o:opList){
			ops[i] = o;
			i++;
		}
		swapOp = new SwapOperation(((JMProblem) problem).getProblem(),ops);
		iBest = getDecisionVariables().variables_;
	}

	public PSOSolution(Solution<T> solution) {
		super(solution);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @return the swapOp
	 */
	public SwapOperation getSwapOp() {
		return swapOp;
	}

	/**
	 * @param swapOp
	 *            the swapOp to set
	 */
	public void setSwapOp(SwapOperation swapOp) {
		this.swapOp = swapOp;
	}

	/**
	 * @return the iBest
	 */
	public List<T> getiBest() {
		return iBest;
	}

	/**
	 * @param iBest
	 *            the iBest to set
	 */
	public void setiBest(List<T> iBest) {
		this.iBest = iBest;
	}
}
